<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelet Title</title>
    </h:head>
    <h:body onload="#{registroControl.carga()}">
        <f:view>
            <f:loadBundle basename="bundle.messages" var="msg"/>
            <h:form id="form_registro">
                <p:panel id="panel_registro" header="#{msg.new_user}">
                    <p:messages id="mgs"/>
                    <h:panelGrid columns="3">
                        <h:outputLabel value="#{msg.user_name}: *" for="nick"/>
                        <p:inputText id="nick" value="#{registroControl.nick}" required="true" label="#{msg.user_name}">
                            <f:validateLength maximum="40"/>
                        </p:inputText>
                        <p:message for="nick" display="icon"/>
                        
                         <h:outputLabel value="#{msg.password}: *" for="password"/>                        
                        <p:password id="password" value="#{registroControl.password}" required="true" 
                                     label="#{msg.password}" binding="#{pass}">
                            <f:validateLength minimum="6" maximum="45"/>
                        </p:password>
                        <p:message for="password" display="icon"/>
                        
                        <h:outputLabel value="#{msg.password_rep}: *" for="password_rep"/>
                        <p:password id="password_rep" value="#{registroControl.password_rep}" required="true" 
                                     label="#{msg.password_rep}" validator="repeatPasswordValidator">
                            <f:attribute name="password" value="#{pass.value}"/>                            
                        </p:password>
                        <p:message for="password_rep" display="icon"/>
                        
                        <h:outputLabel value="#{msg.name}: *" for="nombre"/>
                        <p:inputText id="nombre" value="#{registroControl.nombre}" label="#{msg.name}" required="true">
                            <f:validateLength maximum="65"/>                            
                        </p:inputText>
                        <p:message for="nombre" display="icon"/>
                        
                        <h:outputLabel value="#{msg.email}: *" for ="email"/>
                        <p:inputText id="email" value="#{registroControl.email}" required="true" 
                                     label="#{msg.email}" validator="emailValidator"/>
                        <p:message for="email" display="icon"/>
                        
                        <h:outputLabel value="#{msg.birth_date}: " for="fecha_nac"/>
                        <p:calendar id="fecha_nac" navigator="true" value="#{registroControl.fechaNac}" label="#{msg.birth_date}" 
                                    pattern="dd/MM/yyyy" yearRange="c-80:c"/>
                        <p:message for="fecha_nac" display="icon"/>
                                                                        
                        <h:outputLabel value="#{msg.nacionality}: " for="nacion"/>
                        <h:selectOneMenu id="nacion" value="#{registroControl.nacion}" label="#{msg.nacionality}" required="true">
                            <f:selectItem itemLabel="-#{msg.select_nation}-" />
                            <f:selectItems value="#{registroControl.paisSelect}"/>
                        </h:selectOneMenu>
                        <p:message for="nacion" display="icon"/>
                        
                        <h:outputLabel value="#{msg.sex}: " for="sexo"/>
                        <h:selectOneMenu id="sexo" value="#{registroControl.sexo}">
                            <f:selectItem itemValue="NSP" itemLabel="#{msg.not_specified}"/>
                            <f:selectItem itemValue="MAS" itemLabel="#{msg.masculine}"/>
                            <f:selectItem itemValue="FEM" itemLabel="#{msg.femenine}"/>
                        </h:selectOneMenu>
                        <p:message for="sexo" display="icon"/>
                        
                        
                       <f:facet name="footer"> 
                           <p:commandButton id="borrar" value="#{msg.register}" ajax="false" 
                                            action="#{registroControl.doRegistro()}"/>
                       </f:facet> 
                    </h:panelGrid>
                    
                                  
                </p:panel>                 
            </h:form>
            <h:form>
                <p:commandLink action="#{registroControl.goIndex()}" ajax="false" value="#{msg.returnindex}"/>
            </h:form>
            <h:form>
                <p:dialog id="confirmacion"  header="#{msg.correct_register}" modal="true"
                              widgetVar="confirmacionVar" height="230" closable="false" 
                              visible="#{registroControl.showDialog}" resizable="false"
                              showEffect="explode" hideEffect="bounce">                                
                        <h:outputText value="#{msg.email_sent}"/>
                        <p>
                            <h:commandButton id="btdialog" value="#{msg.accept}"  
                                         actionListener="#{registroControl.handleClose(event)}"/>
                        </p>
                </p:dialog>  
            </h:form>
        </f:view>
    </h:body>
</html>
